# deployment.yaml.tpl - 针对测试项目优化
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${CI_PROJECT_NAME}
  labels:
    app: ${CI_PROJECT_NAME}
    version: "${CI_COMMIT_SHORT_SHA}"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ${CI_PROJECT_NAME}
  template:
    metadata:
      labels:
        app: ${CI_PROJECT_NAME}
        version: "${CI_COMMIT_SHORT_SHA}"
    spec:
      containers:
      - name: ${CI_PROJECT_NAME}
        image: ${PRIVATE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "512Mi"
            cpu: "250m"
          limits:
            memory: "1024Mi"
            cpu: "500m"
        livenessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 120  # 增加初始延迟
          periodSeconds: 10
        readinessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 60   # 增加初始延迟
          periodSeconds: 5
      imagePullSecrets:
        - name: regcred
      restartPolicy: Always

---
apiVersion: v1
kind: Service
metadata:
  name: ${CI_PROJECT_NAME}-svc
spec:
  selector:
    app: ${CI_PROJECT_NAME}
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
      nodePort: ${NODE_PORT}
  type: NodePort